import useActionControl from '@/hooks/useActionControl';
import SystemDictDataSelect from '@/pages/system/dictData/references/SystemDictDataSelect';
import ApiMonitorOperlog from '@/services/monitor/ApiMonitorOperlog';
import { ProTable } from '@ant-design/pro-components';

const SystemLogOperlogIndex = () => {
  const actionControl = useActionControl({});

  return (
    <div>
      <ProTable
        {...actionControl.table}
        request={async (params: any) => {
          const data = await ApiMonitorOperlog.list(params);
          return {
            data: data.rows,
            success: true,
            total: data.total,
          };
        }}
        rowKey={'operId'}
        columns={[
          { title: '日志编号', dataIndex: 'operId', hideInSearch: true },
          { title: '系统模块', dataIndex: 'title' },
          {
            title: '操作类型',
            dataIndex: 'businessType',
            renderText: (_, record) => (
              <SystemDictDataSelect
                typeCode={'sys_oper_type'}
                readonly
                valueInLabel={false}
                value={record.businessType}
              />
            ),
            renderFormItem: () => (
              <SystemDictDataSelect
                typeCode={'sys_oper_type'}
                valueInLabel={false}
              />
            ),
          },
          { title: '操作人员', dataIndex: 'operName' },
          { title: '操作地址', dataIndex: 'operIp' },
          {
            title: '操作状态',
            dataIndex: 'status',
            renderText: (_, record) => (
              <SystemDictDataSelect
                typeCode={'sys_common_status'}
                value={record.status}
                valueInLabel={false}
                readonly
              />
            ),
            renderFormItem: () => {
              return (
                <SystemDictDataSelect
                  typeCode={'sys_common_status'}
                  valueInLabel={false}
                />
              );
            },
          },

          {
            title: '操作日期',
            dataIndex: 'operTime',
            valueType: 'dateTime',
            hideInSearch: true,
          },
          {
            title: '操作日期',
            dataIndex: 'operTime',
            valueType: 'dateTimeRange',
            hideInTable: true,
          },
        ]}
      />
    </div>
  );
};

export default SystemLogOperlogIndex;
